import unittest
import Cryptography.PlayfairCipher


class PlayfairCipherTests(unittest.TestCase):
    """description of class"""
    
    def test_GetNextPosition_Normal(self):
        input_x = 0
        input_y = 0
        size_x = 5
        size_y = 5

        expect = Cryptography.PlayfairCipher.GetNextPosition(input_x, input_y, size_x, size_y)

        self.assertEqual(0, expect[0])
        self.assertEqual(1, expect[1])

    def test_GetNextPosition_AtEndOfLine(self):
        input_x = 0
        input_y = 4
        size_x = 5
        size_y = 5

        expect = Cryptography.PlayfairCipher.GetNextPosition(input_x, input_y, size_x, size_y)

        self.assertEqual(1, expect[0])
        self.assertEqual(0, expect[1])

    def test_GetNextPosition_AtBottomRight(self):
        input_x = 4
        input_y = 4
        size_x = 5
        size_y = 5

        expect = Cryptography.PlayfairCipher.GetNextPosition(input_x, input_y, size_x, size_y)

        self.assertEqual(-1, expect[0])
        self.assertEqual(-1, expect[1])



    def test_ChangePosition_Rectangle(self):
        newPositions = Cryptography.PlayfairCipher.ChangePosition(0, 0, 2, 2, 5, 5)

        self.assertEqual(len(newPositions), 2)
        self.assertEqual(newPositions[0][0], 2)
        self.assertEqual(newPositions[0][1], 0)
        self.assertEqual(newPositions[1][0], 0)
        self.assertEqual(newPositions[1][1], 2)

    def test_ChangePosition_SameColumn(self):
        newPositions = Cryptography.PlayfairCipher.ChangePosition(1, 0, 1, 4, 5, 5)

        self.assertEqual(len(newPositions), 2)
        self.assertEqual(newPositions[0][0], 1)
        self.assertEqual(newPositions[0][1], 1)
        self.assertEqual(newPositions[1][0], 1)
        self.assertEqual(newPositions[1][1], 0)

    def test_ChangePosition_SameRow(self):
        newPositions = Cryptography.PlayfairCipher.ChangePosition(0, 2, 4, 2, 5, 5)

        self.assertEqual(len(newPositions), 2)
        self.assertEqual(newPositions[0][0], 1)
        self.assertEqual(newPositions[0][1], 2)
        self.assertEqual(newPositions[1][0], 0)
        self.assertEqual(newPositions[1][1], 2)